package com.br.cashflowdao.hibernate.dao.entities;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author Marcel Sena <marcel.sena at marcel.sena@gmail.com>
 * @version 1.0
 * @since 05/01/2009
 */
@Entity
@Table(name="CREDIT_TRANSACTION"
        ,catalog="cashflow"
    )
public class CreditTransaction  implements java.io.Serializable, IEntity {

     private Long id;
     private TransferTransaction transferTransaction;
     private Account account;
     private Category category;
     private BigDecimal amount;
     private Date createDate;
     private Date creditDate;
     private String description;
     private Payee payee;
     private Date updateDate;

    public CreditTransaction() {}
	
    @Id
    @GeneratedValue(strategy=IDENTITY)
    @Column(name="ID", unique=true, nullable=false)
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }

    @OneToOne(optional=true, mappedBy="creditTransaction")
    public TransferTransaction getTransferTransaction() {
        return this.transferTransaction;
    }
    
    public void setTransferTransaction(TransferTransaction transferTransaction) {
        this.transferTransaction = transferTransaction;
    }

    @ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH})
    @JoinColumn(name="ACCOUNT_ID", nullable=false)
    public Account getAccount() {
        return this.account;
    }
    
    public void setAccount(Account account) {
        this.account = account;
    }

    @ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH})
    @JoinColumn(name="CATEGORY_ID", nullable=false)
    public Category getCategory() {
        return this.category;
    }
    
    public void setCategory(Category category) {
        this.category = category;
    }
    
    @Column(name="AMOUNT", nullable=false, precision=10, scale=2)
    public BigDecimal getAmount() {
        return this.amount;
    }
    
    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    @Temporal(TemporalType.DATE)
    @Column(name="CREATE_DATE", nullable=false, length=10)
    public Date getCreateDate() {
        return this.createDate;
    }
    
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    @Temporal(TemporalType.DATE)
    @Column(name="CREDIT_DATE", nullable=false, length=10)
    public Date getCreditDate() {
        return this.creditDate;
    }
    
    public void setCreditDate(Date creditDate) {
        this.creditDate = creditDate;
    }
    
    @Column(name="DESCRIPTION", nullable=true, length=255)
    public String getDescription() {
        return this.description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    @ManyToOne(fetch=FetchType.EAGER, cascade=CascadeType.REFRESH)
    @JoinColumn(name="PAYEE_ID", nullable=false)
    public Payee getPayee() {
        return this.payee;
    }

    public void setPayee(Payee payee) {
        this.payee = payee;
    }

    @Temporal(TemporalType.DATE)
    @Column(name="UPDATE_DATE", nullable=false, length=10)
    public Date getUpdateDate() {
        return this.updateDate;
    }
    
    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }
}